<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<script src="./vue.js"></script>
<script src="./vuex.js"></script>

<body>
  <div id="app">
    <p>{{name}}</p>
  </div>

  <script>
    // 创建store实例对象
    const store = new Vuex.Store({
      state: {
        name: "Vuex.js的直接引用",
      }
    })

    const vm = new Vue({
      el: "#app",
      // 使用计算属性返回state中name
      computed: {
        name() {
          return this.$store.state.name;
        }
      },
      store,
    })
  </script>
</body>

</html>